class Solution:
    def getSteps(self, first, last, n):
        steps = 0
        while first <= n:
            steps += min(last, n) - first + 1
            first = 10 * first
            last = 10 * last + 9
        return steps

    def findKthNumber(self, n, k):
        cur = 1
        k -= 1
        while k:
            steps = self.getSteps(10 * cur, 10 * cur + 9, n)
            if steps < k:
                k = k - steps - 1
                cur += 1
            else:
                k -= 1
                cur *= 10
        return cur


data = Solution()
n = 390
k = 130
print(data.findKthNumber(n, k))
